package com.yowasa.xiuxian.engine.battle.strategy.skill.fire;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name="炼火诀")
@Order(501)
@Component
public class LianHuoJue extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;
    @Override
    public ElementEnum getElement() {
        return ElementEnum.FIRE;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int orgAtk = first.getBattleInfo().getSpell();
        int def = second.getBattleInfo().getRes();
        int dmg = (int) (battleHelper.calSpell(orgAtk,def) * 3.5);
        first.getBattleInfo().setCmp(first.getBattleInfo().getCmp() - orgAtk);
        battleHelper.autoAction(this, first, second, content, dmg, "炼火诀");
        first.getCd().put("炼火诀", 4);
    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("火") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用炼火诀必须具有火灵根");
        }
    }
    @Override
    public String limitDesc() {
        return "具有火灵根";
    }

    @Override
    public String desc() {
        return "cd3回合 蓝耗1.0倍术法攻击力造成3.5倍术法攻击伤害";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        Integer cd = user.getCd().get("炼火诀");
        if (cd != null && cd > 0) {
            return false;
        }
        int orgAtk = user.getBattleInfo().getSpell();
        if (user.getBattleInfo().getCmp() < orgAtk) {
            return false;
        }
        return true;
    }
}
